This application relates to and incorporates herein by reference Japanese Patent Application No. 10-198253 filed on Jul. 14, 1998.
1. Field of the Invention
The present invention relates to an electronic control apparatus, which has a function of control based on an application program stored in a rewritable nonvolatile memory and a function of rewriting the application program.
2. Description of Related Art
An electronic control apparatus conventionally has a rewritable nonvolatile memory such as a flash ROM, which stores a control program for controlling a predetermined control object such as an internal combustion engine. It is known that the electronic control apparatus executes a predetermined control by jumping to the control program when a request of rewriting the control program stored in the rewritable nonvolatile memory is issued.
If the control program has not been written into the rewritable nonvolatile memory or has been written incompletely only partly in the electronic control apparatus for some reason, such an incomplete operation occurs that the control object can not be controlled normally even when the electronic control apparatus executes the control program. This problem may be countered by providing data, which indicate whether the control program is written, in a specified address in the rewritable nonvolatile memory, and waiting for a rewriting request in a boot program (starting program) stored in the rewritable nonvolatile memory along with the control program when it is determined with the data that the control program has not been written.
It is only required in the above apparatus that the data indicative of the presence/absence of the control program is provided in the specified address to determine the presence/absence of the control program for controlling the predetermined control object, and that the boot program is required to check the data in that address. The control program, however, is required to have its own data to indicate its own presence/absence. This disables changing an address construction.
That is, in the conventional determination of the presence and absence of an application program, the presence/absence of the application program is determined by providing 00h as the specific data at the specified address of the application program, for instance at the last of the application program, and by reading the data in that address by the boot program and determining whether it is 00h. Here, h of 00h denotes the hexadecimal number (in hexadecimal notation), and 00h (hexadecimal notation) indicates 0 (decimal notation) in which all 8 bits (1 byte) are 0.
Thus, when the application program is altered to cause a change in its size, the address for the data which indicates the presence/absence of the application program also changes. As a result, the boot program is also required to be changed. Further, when the program in other storage areas has been altered in part erroneously although the data which indicates the presence/absence of the application program indicates the presence of data, the program runs erroneously and causes erroneous operation when the processing jumps to the application program.
Therefore, processing may be held in an endless wait condition (e.g., for a rewriting command) by an erroneous determination of the presence/absence of the control program such that the control object can not be controlled normally when only the data is present but the program has been erased. This problem may be countered by providing boot program logic for determining the presence/absence of the control program in more detail. However, the boot program (which will not be rewritten again in general) would then be made complicated and large sized. In addition, flexible counter measures can not be taken against the control program, which requires different determination logic for determining its presence or absence to cope with different constructions.
The present invention has been attained to solve the above problems and has an object to provide an electronic control apparatus, which has a control program for controlling a predetermined control object and a determination logic for determining its presence/absence in a rewritable nonvolatile memory and proceeds to execute the control program to control the control object only when the control program has been written.
According to an electronic control apparatus of the present invention, when it is determined by a determination program in a rewritable nonvolatile memory that a control program for controlling a predetermined object is to be executed, it is confirmed first that a check program is present in a predetermined address area in a storage area for storing the control program, and then the processing proceeds to the control program after an execution of the check program. The control program is executed actually only when the presence of the control program is confirmed by the check program beforehand. Thus, it will not occur that the processing jumps erroneously to the control program when the control program is not present, and an erroneous operation due to erroneous execution of the program can be restricted. Further, the check program for confirming the presence/absence of the control program is set in a predetermined address in the storage area of the control program. Thus, the address. of the data, which indicates the presence/absence of the control program, does not change even when the control program is altered and its size is changed. As a result, a determination program e a small one which is simple and does not require changes, thus providing flexibility against changes in the control program.